Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@toolz/session-storage-is-available
Advanced tools
A simple utility function to safely determine whether sessionStorage is available in the current environment
session-storage-is-available
is a tiny utility function to safely determine whether sessionStorage is available in the current environment. It's dangerous to assume that sessionStorage()
is available. It can be absent in non-supported browsers, or when scripts are invoked from the command line, or when the user's browser is in Incognito Mode. Trying to access sessionStorage()
when it's unavailable can spawn an Error
. So it's best to test for its existence before attempting to access it.
After installation, import the package:
import { sessionStorageIsAvailable } from '@toolz/session-storage-is-available';
sessionStorageIsAvailable()
attempts to set-and-remove a value in sessionStorage
, returning a Boolean value based on its failure or success.
const API = {
arguments: {
// none
},
returns: Boolean,
}
Examples:
sessionStorageIsAvailable(); // returns Boolean TRUE in "normal" browser situations
sessionStorageIsAvailable(); // returns Boolean FALSE when invoked outside a "normal" browser
// or when the browser can sessionStorage disabled (e.g., Incognito Mode)
FAQs
A simple utility function to safely determine whether sessionStorage is available in the current environment
The npm package @toolz/session-storage-is-available receives a total of 422 weekly downloads. As such, @toolz/session-storage-is-available popularity was classified as not popular.
We found that @toolz/session-storage-is-available demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.